#include <stdio.h>
#include <windows.h>
#include "UBigNumber.h"
#include "UBigNumber.c"

int main()
{
    struct UBigNumber A, B, C, D;
    int compare;
    char asign=0, bsign=0;
    asign = getchar();
    if(asign == '-')
    {
        A = InputUBN(0); //无符号大数输入
    }
    else
    {
        A = InputUBN(asign);
    }
    bsign = getchar();
    if (bsign == '-')
    {
        B = InputUBN(0); //无符号大数输入
    }
    else
    {
        B = InputUBN(bsign);
    }
    //比较无符号大小
    compare = CompareUBN(&A, &B);
    //有符号相加
    if (asign == '-' && bsign != '-')
    {
        if(compare == 1)
        {
            C = MinusUBN(&A, &B);
            printf("-");
            PrintUBN(C);
            printf("\n");
        }
        else if(compare == -1)
        {
            C = MinusUBN(&B, &A);
            PrintUBN(C);
            printf("\n");
        }
        else
        {
            printf("0\n");
        }
    }
    else if (asign == '-' && bsign == '-')
    {
        C = AddUBN(&A, &B);
        printf("-");
        PrintUBN(C);
        printf("\n");
    }
    else if (asign != '-' && bsign == '-')
    {
        if(compare == 1)
        {
            C = MinusUBN(&A, &B);
            PrintUBN(C);
            printf("\n");
        }
        else if(compare == -1)
        {
            C = MinusUBN(&B, &A);
            printf("-");
            PrintUBN(C);
            printf("\n");
        }
        else
        {
            printf("0\n");
        }
    }
    else if (asign != '-' && bsign != '-')
    {
        C = AddUBN(&A, &B);
        PrintUBN(C);
        printf("\n");
    }
    //有符号相减
    if(asign == '-' && bsign != '-')
    {
        D = AddUBN(&A, &B); //无符号大数相减
        printf("-");
        PrintUBN(D);
        printf("\n");
    }
    else if (asign == '-' && bsign == '-')
    {
        if(compare == 1)
        {
            D = MinusUBN(&A, &B);
            printf("-");
            PrintUBN(D);
            printf("\n");
        }
        else if(compare == -1)
        {
            D = MinusUBN(&B, &A);
            PrintUBN(D);
            printf("\n");
        }
        else
        {
            printf("0\n");
        }
    }
    else if (asign != '-' && bsign == '-')
    {
        D = AddUBN(&A, &B); //无符号大数相减
        PrintUBN(D);
        printf("\n");
    }
    else if (asign != '-' && bsign != '-')
    {
        if(compare == 1)
        {
            D = MinusUBN(&A, &B); //无符号大数相减
            PrintUBN(D);
            printf("\n");
        }
        else if(compare == -1)
        {
            D = MinusUBN(&B, &A);
            printf("-");
            PrintUBN(D);
            printf("\n");
        }
        else
        {
            printf("0\n");
        }
    }

    DestoryUBN(&A); //销毁无符号大数
    DestoryUBN(&B);
    DestoryUBN(&D);
    system("pause");
    return 0;
}
